﻿#include "OperGeometryFeatureCreation.h"
#include "FITK_Kernel/FITKAppFramework/FITKGlobalData.h"
#include "FITK_Kernel/FITKAppFramework/FITKAppFramework.h"
#include "OperatorsInterface/GraphEventOperator.h"
#include <QWidget>
#include "GUIDialog/GUIGeometryDialog/GUIGeometryStretchDialog.h"
#include "GUIDialog/GUIGeometryDialog/GUIGeometryRotateDialog.h"
#include "GUIDialog/GUIGeometryDialog/GUIGeometrySweepDialog.h"
#include "GUIDialog/GUIGeometryDialog/GUIGeometryLoftingDialog.h"

bool ModelOper::OperGeometryFeatureCreation::execGUI() {
    //获取动作名称
    if (_emitter == nullptr)
    {
        return false;
    }
    QString actionName = _emitter->objectName();
    if (actionName == "actionSweep")//扫掠
    {
        this->createSweepOper();
    }
    else if (actionName == "actionRotate")//旋转
    {
        this->createRotateOper();
    }
    else if (actionName == "actionStretch")//拉伸
    {
        this->createStretchOper();
    }
    else if (actionName == "actionLofting")//放样
    {
        this->createLoftingOper();
    }
    return false;
}

bool ModelOper::OperGeometryFeatureCreation::execProfession()
{
    int objID = -1;
    this->argValue("objID", objID);
    //获取三维可视对象数据-用于渲染数据对象
    EventOper::GraphEventOperator* graphOper = FITKOPERREPO->getOperatorT<EventOper::GraphEventOperator>("GraphPreprocess");
    if (graphOper == nullptr)return false;
    graphOper->updateGraph(objID);
    return true;
}



bool ModelOper::OperGeometryFeatureCreation::createStretchOper()
{
    //主界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometryStretchDialog* dialog = new GUI::GUIGeometryStretchDialog(this, mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryFeatureCreation::execProfession);
    dialog->show();
    return true;
}

bool ModelOper::OperGeometryFeatureCreation::createRotateOper()
{
    //创建旋转窗口
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometryRotateDialog* dialog = new GUI::GUIGeometryRotateDialog(this, mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryFeatureCreation::execProfession);
    dialog->show();
    return true;
}

bool ModelOper::OperGeometryFeatureCreation::createSweepOper()
{
    //扫掠界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometrySweepDialog* dialog = new GUI::GUIGeometrySweepDialog(this, mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryFeatureCreation::execProfession);
    dialog->show();
    return true;
}

bool ModelOper::OperGeometryFeatureCreation::createLoftingOper()
{
    //放样界面
    QWidget* mw = FITKAPP->getGlobalData()->getMainWindow();
    if (!mw) return false;
    //创建界面
    GUI::GUIGeometryLoftingDialog* dialog = new GUI::GUIGeometryLoftingDialog(this, mw);

    //当界面执行完毕后执行
    connect(dialog, &QDialog::accepted, this, &OperGeometryFeatureCreation::execProfession);
    dialog->show();
    return true;
}

